import request from "@/utils/request";
import {
  ResRolesList,
  ResPermissionsList,
  UpdateRolePermissionParams,
  AddRoleParams,
} from "./model";
export const reqRolesList = (data: PageQuery) => {
  return request<any, PageResult<ResRolesList[]>>({
    url: "/admin/rolelist",
    params: data,
  });
};

// 获取权限列表
export const reqPermissionsList = () => {
  return request<any, ResPermissionsList[]>({
    url: "/admin/permissionlist",
  });
};

// 更改权限
export const reqUpdateRolePermission = (data: UpdateRolePermissionParams) => {
  return request({
    url: "/admin/roleupdate",
    method: "put",
    data,
  });
};

// 删除角色
export const reqDelRole = (id: number) => {
  return request({
    url: `/admin/roledelete?id=${id}`,
  });
};

// 添加角色
export const reqAddRole = (data: AddRoleParams) => {
  return request({
    url: `/admin/rolecreate`,
    method: "post",
    data,
  });
};
